/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package manager;
import Entity.Single;
import iface.IManager;
import java.util.ArrayList;
/**
 *
 * @author BinhNV_A04911
 */
public class SingleManager  implements IManager<Single>{
    private ArrayList<Single> Singlelist;
   public SingleManager(){
       this.Singlelist=new ArrayList<Single>();
   }
    public boolean add(Single obj) {
       return this.Singlelist.add(obj);
    }

    public boolean remove(Single obj) {
      return this.Singlelist.remove(obj);

    }

    public Single replace(int index, Single obj) {
       return  this.Singlelist.set(index, obj);
    }

    public int size() {
       return this.Singlelist.size();
    }

    public Single get(int index) {
      return this.Singlelist.get(index);
    }

    public Single getById(int id) {
       for(Single objSingle:this.Singlelist){
           if(Integer.valueOf(objSingle.getSingleID())==id){
               return objSingle;
           }
       }
       return null;
    }

    public Single getByName(String name) {
       for(Single obj:this.Singlelist){
           if(obj.equals(obj)){
               return obj;
           }
       }
       return null;
    }

    public void setVisible(Single obj, boolean value) {
        for(Single objSingle:this.Singlelist){
            if(objSingle.equals(objSingle.getSingleID())){
                objSingle.setStatus(value);
                break;
            }
        }
    }

}
